home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10051 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: nuhou.aloha.net!coconut!usenet
  2. From: Dave Carien <davec@hawaii.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Standard question - pointer initialization
  5. Date: Thu, 14 Mar 1996 18:38:29 -0800
  6. Organization: KnightSoft/Voyager
  7. Message-ID: <3148D825.945@hawaii.edu>
  8. References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl>
  9.         <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com>
  10.         <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com> <TANMOY.96Mar13184413@qcd.lanl.gov>
  11. NNTP-Posting-Host: dialup61.aloha.com
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=us-ascii
  14. Content-Transfer-Encoding: 7bit
  15. X-Mailer: Mozilla 2.0 (Win16; I)
  16.  
  17. Tanmoy Bhattacharya wrote:
  18. > In article <4i7cgn$5da@baygull.rtd.com>
  19. > collins@RTD.COM (Ronald Collins) writes:
  20. > <snip>
  21. > RC: : Also note that NULL is just a macro that stands for the value zero (often
  22. > RC: : accompanied by a cast to void *). In assigning default initialization values to
  23. > RC: : static variables, the compiler couldn't care less that there is a pre-processor
  24. > RC: : macro called NULL. NULL can never be anything other than zero in a
  25. > RC: : standard-conforming implementation of the C language.
  26. > RC:
  27. > RC: This may be true on _your_ implementation, but nothing in the standard
  28. > RC: requires the NULL value to be numerically 0.
  29. > RC:
  30. > RC: Please read the FAQ before posting on the subject again.
  31. > Confusion reigns!
  32. > NULL is a macro which is defined in a number of standard headers. It
  33. > is guaranteed to be an integral constant (roughly, compile time
  34. > integral constant which does not depend on floating ot pointer
  35. > arithmetic) with the value 0; or such a quantity cast to (void*).
  36. > Thus it could be 0, (1-1), (void*)0, __builtin_null (with a previous
  37. > enum __builtin_tag { __builtin_null }; explicit or assumed), or an
  38. > infinity of other forms. However, informally, all of these are zeros.
  39. > In a context where the compiler _knows_ that a pointer is required,
  40. > the compiler shall automatically converted all integral constant zeros
  41. > to a null pointer. The representation of this null pointer may
  42. > actually depend on its type, and has no relation to zero. This is what
  43. > the FAQ file was trying to explain.
  44.  
  45.  
  46. I was under the impression that NULL was a pointer type and to convert it 
  47. to a char type it you would need to do something such as:
  48.  
  49. (char)NULL
  50.  
  51. Of course it would be wiser to use '\0', or just 0 for an int typecast.
  52. If I'm wrong I'm sorry.
  53.  
  54. davec@hawaii.edu
  55.